Skip to content

Conversation

@skewb1k
Copy link
Contributor

@skewb1k skewb1k commented Aug 2, 2025

Previously, get_relative_line_num() did not account for window, which caused incorrect relative line numbers with multiwindow option.

Steps to reproduce

  1. minimal.lua
vim.o.number = true
vim.o.relativenumber = true

vim.pack.add({
	{ src = "https://github.com/nvim-treesitter/nvim-treesitter" },
	{ src = "https://github.com/nvim-treesitter/nvim-treesitter-context" },
})

require("nvim-treesitter.configs").setup({
	ensure_installed = { "json" },
})

require("treesitter-context").setup({
	mode = "topline",
	multiwindow = true,
})
  1. Make the context appear
1754166394_screenshot
  1. Open a second window (e.g., with :sf, :copen, or <F1>).
1754166399_screenshot

Relative line numbers in the context become incorrect in the non-active window.

This fix ensures that the cursor line number is calculated per-window by passing the appropriate winid.

@lewis6991
Copy link
Member

Lots of unrelated changes in this PR

@skewb1k
Copy link
Contributor Author

skewb1k commented Aug 2, 2025

Yeah, the inconsistency in naming win vs winid became more obvious once it had to be passed through the whole call stack.
Do you disagree with this change, or would you prefer it to be in a separate commit or PR?

Previously, `get_relative_line_num()` did not account for window,
which caused incorrect relative line numbers with multiwindow option.
Copy link
Member

@lewis6991 lewis6991 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On mobile which has a bug that doesn't let me merge. Will merge asap. Thanks

@lewis6991 lewis6991 merged commit dca8726 into nvim-treesitter:master Aug 6, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants